#include<bits/stdc++.h>
using namespace std;
bool bg;
namespace INPUT_SPACE{
	const int S=(1<<20)+5;char B[S],*H,*T;inline int gc() { if(H==T) T=(H=B)+fread(B,1,S,stdin);return (H==T)?EOF:*H++; }
	inline unsigned int inn() { unsigned int x,ch;while((ch=gc())<'0'||ch>'9');x=ch^'0';while((ch=gc())>='0'&&ch<='9') x=x*10+(ch^'0');return x; }
}using INPUT_SPACE::inn;

namespace GENERATE_VALUE_SPACE{
	unsigned int _gen(unsigned int x,unsigned int A,unsigned int B,unsigned int C) { return A*x*x+B*x+C; }
	void gen_value(unsigned int *a,int n,unsigned int A,unsigned int B,unsigned int C,unsigned int a0)
	{ a[1]=_gen(a0,A,B,C);for(int i=2;i<=n;i++) a[i]=_gen(a[i-1],A,B,C); }
}using GENERATE_VALUE_SPACE::gen_value;
unsigned int a[7000000+100];
int fa[7000000+100];
//short bl[7000000+10];
bitset<7000010> mark;
random_device seed;
mt19937 mt(seed());
bool ed;
int subtask_id,n,q;
void init(){
	int vcnt = sqrt(n);
	vector<int> vps;
	vps.push_back(1);
	mark[1] = 1;
	for(int i = 1;i<=vcnt;i++){
		int cur = mt()%n + 1;
		vps.push_back(cur);
		while(!mark[cur]){
			mark[cur] = 1;
		}
		vps.push_back(cur);
	}
	sort(vps.begin(),vps.end());
	vps.erase(unique(vps.begin(),vps.end()),vps.end());

}
void update(int x,int y,unsigned int v) { /*do the update*/ }
unsigned int query(int x,int y) { /*do the query*/unsigned int ans=0; return ans; }
int main()
{
	std::cerr<<(&ed - &bg)/1048576.0<<'\n';
	subtask_id=inn(),n=inn(),q=inn();
	unsigned int A=inn(),B=inn(),C=inn(),a0=inn();
	GENERATE_VALUE_SPACE::gen_value(a,n,A,B,C,a0);
	for(int i=2;i<=n;i++) fa[i]=inn();
	


	unsigned int last_ans=0;
	for(int i=1;i<=q;i++)
	{
		int t=inn();
		int P=last_ans&((1<<20)-1);
		if(t==0)
		{
			int x=inn()^P,y=inn()^P;
			unsigned int v=inn()^P;
			update(x,y,v);
		}
		else{
			int x=inn()^P,y=inn()^P;
			printf("%u\n",last_ans=query(x,y));
		}
	}
	return 0;
}
